Lokasi ngalangkungan proxy:   [ UP ]  
[Ngawartoskeun bug]   [Panyetelan cookie]                
Skip to content

fix(bigtable): forward enable_server_retries in AsyncBulkApplier - #16739

Open
sushanb wants to merge 3 commits into
googleapis:mainfrom
sushanb:fix/bigtable-async-bulk-apply-server-retries
Open

sushanb wants to merge 3 commits into
googleapis:mainfrom
sushanb:fix/bigtable-async-bulk-apply-server-retries

Conversation

@sushanb

@sushanb sushanb commented Dec 2, 2026

Copy link
Copy Markdown
Contributor

Summary

  • Forward enable_server_retries_ to BulkMutatorState::OnFinish in AsyncBulkApplier::OnFinish so unconfirmed non-idempotent mutations are retried when server retries are enabled and the MutateRows stream status carries google.rpc.RetryInfo.
  • Remove the error-prone default = false argument on BulkMutatorState::OnFinish so callers must explicitly pass enable_server_retries.

Testing

  • Added unit tests covering server-directed retries for non-idempotent mutations in google/cloud/bigtable/internal/async_bulk_apply_test.cc and google/cloud/bigtable/internal/bulk_mutator_test.cc.
  • Verified bazel test //google/cloud/bigtable:internal_async_bulk_apply_test //google/cloud/bigtable:internal_bulk_mutator_test.

…inish

Pass enable_server_retries_ to BulkMutatorState::OnFinish in AsyncBulkApplier::OnFinish so unconfirmed non-idempotent mutations are retried when server retries are enabled and the MutateRows stream status carries google.rpc.RetryInfo. Remove the default false argument on BulkMutatorState::OnFinish to prevent callers from omitting it.
@sushanb
sushanb requested a review from a team as a code owner December 2, 2026 17:10
@sushanb
sushanb requested a review from scotthart December 2, 2026 17:10
@product-auto-label product-auto-label Bot added the api: bigtable Issues related to the Bigtable API. label Dec 2, 2026

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request updates AsyncBulkApplier and BulkMutatorState to propagate the enable_server_retries flag during bulk apply operations. In compliance with the repository style guide, default parameters in the internal namespace have been removed from OnFinish, requiring callers to explicitly specify the retry behavior. Additionally, comprehensive unit tests have been added to verify that server retries are correctly handled or ignored for non-idempotent mutations. The review feedback highlights several violations of the style guide regarding the use of auto where it obscures domain types, return types, or protobuf messages, suggesting explicit types instead.

});
CompletionQueue cq(mock_cq);

auto retry = DataLimitedErrorCountRetryPolicy(kNumRetries).clone();

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

According to the style guide, auto should not be used when it obscures function return types. Please use the explicit type std::unique_ptr<bigtable::RPCRetryPolicy> instead.

  std::unique_ptr<bigtable::RPCRetryPolicy> retry =
      DataLimitedErrorCountRetryPolicy(kNumRetries).clone();
References
  1. Reject Obscured Domain & Return Types: Flag and reject auto when it hides StatusOr, domain objects, protobuf messages/fields, or function return types. (link)

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Addressed in 8127c9b: replaced auto with the explicit return type.

auto retry = DataLimitedErrorCountRetryPolicy(kNumRetries).clone();
auto mock_b = std::make_unique<MockBackoffPolicy>();
EXPECT_CALL(*mock_b, OnCompletion).Times(2);
auto idempotency = bigtable::DefaultIdempotentMutationPolicy();

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

According to the style guide, auto should not be used when it obscures function return types. Please use the explicit type std::shared_ptr<bigtable::IdempotentMutationPolicy> instead.

  std::shared_ptr<bigtable::IdempotentMutationPolicy> idempotency =
      bigtable::DefaultIdempotentMutationPolicy();
References
  1. Reject Obscured Domain & Return Types: Flag and reject auto when it hides StatusOr, domain objects, protobuf messages/fields, or function return types. (link)

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Addressed in 8127c9b: replaced auto with the explicit return type.

EXPECT_CALL(*mock_b, OnCompletion).Times(2);
auto idempotency = bigtable::DefaultIdempotentMutationPolicy();

auto actual = AsyncBulkApplier::Create(

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

According to the style guide, auto should not be used when it obscures function return types. Please use the explicit type google::cloud::future<std::vector<bigtable::FailedMutation>> instead.

  google::cloud::future<std::vector<bigtable::FailedMutation>> actual =
      AsyncBulkApplier::Create(
References
  1. Reject Obscured Domain & Return Types: Flag and reject auto when it hides StatusOr, domain objects, protobuf messages/fields, or function return types. (link)

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Addressed in 8127c9b: replaced auto with the explicit return type.

EXPECT_CALL(*mock_cq, MakeRelativeTimer).Times(0);
CompletionQueue cq(mock_cq);

auto retry = DataLimitedErrorCountRetryPolicy(kNumRetries).clone();

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

According to the style guide, auto should not be used when it obscures function return types. Please use the explicit type std::unique_ptr<bigtable::RPCRetryPolicy> instead.

  std::unique_ptr<bigtable::RPCRetryPolicy> retry =
      DataLimitedErrorCountRetryPolicy(kNumRetries).clone();
References
  1. Reject Obscured Domain & Return Types: Flag and reject auto when it hides StatusOr, domain objects, protobuf messages/fields, or function return types. (link)

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Addressed in 8127c9b: replaced auto with the explicit return type.

auto retry = DataLimitedErrorCountRetryPolicy(kNumRetries).clone();
auto mock_b = std::make_unique<MockBackoffPolicy>();
EXPECT_CALL(*mock_b, OnCompletion).Times(0);
auto idempotency = bigtable::DefaultIdempotentMutationPolicy();

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

According to the style guide, auto should not be used when it obscures function return types. Please use the explicit type std::shared_ptr<bigtable::IdempotentMutationPolicy> instead.

  std::shared_ptr<bigtable::IdempotentMutationPolicy> idempotency =
      bigtable::DefaultIdempotentMutationPolicy();
References
  1. Reject Obscured Domain & Return Types: Flag and reject auto when it hides StatusOr, domain objects, protobuf messages/fields, or function return types. (link)

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Addressed in 8127c9b: replaced auto with the explicit return type.

EXPECT_CALL(*mock_b, OnCompletion).Times(0);
auto idempotency = bigtable::DefaultIdempotentMutationPolicy();

auto actual = AsyncBulkApplier::Create(

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

According to the style guide, auto should not be used when it obscures function return types. Please use the explicit type google::cloud::future<std::vector<bigtable::FailedMutation>> instead.

  google::cloud::future<std::vector<bigtable::FailedMutation>> actual =
      AsyncBulkApplier::Create(
References
  1. Reject Obscured Domain & Return Types: Flag and reject auto when it hides StatusOr, domain objects, protobuf messages/fields, or function return types. (link)

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Addressed in 8127c9b: replaced auto with the explicit return type.

}

TEST_F(BulkMutatorTest, StateOnFinishServerRetries) {
auto policy = DefaultIdempotentMutationPolicy();

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

According to the style guide, auto should not be used when it obscures function return types. Please use the explicit type std::shared_ptr<IdempotentMutationPolicy> instead.

  std::shared_ptr<IdempotentMutationPolicy> policy =
      DefaultIdempotentMutationPolicy();
References
  1. Reject Obscured Domain & Return Types: Flag and reject auto when it hides StatusOr, domain objects, protobuf messages/fields, or function return types. (link)

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Addressed in 8127c9b: replaced auto with the explicit return type.

Comment on lines +890 to +891
auto retry_status =
google::cloud::internal::ResourceExhaustedError("try again");

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

According to the style guide, auto should not be used when it obscures function return types. Please use the explicit type Status instead.

  Status retry_status =
      google::cloud::internal::ResourceExhaustedError("try again");
References
  1. Reject Obscured Domain & Return Types: Flag and reject auto when it hides StatusOr, domain objects, protobuf messages/fields, or function return types. (link)

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Addressed in 8127c9b: replaced auto with the explicit return type.

bigtable_internal::BulkMutatorState state_enabled(
kAppProfile, kTableName, *policy,
BulkMutation(NonIdempotentMutation("r0"), NonIdempotentMutation("r1")));
auto const& req1 = state_enabled.BeforeStart();

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

According to the style guide, auto should not be used when it hides protobuf messages. Please use the explicit type google::bigtable::v2::MutateRowsRequest const& instead.

  google::bigtable::v2::MutateRowsRequest const& req1 =
      state_enabled.BeforeStart();
References
  1. Reject Obscured Domain & Return Types: Flag and reject auto when it hides StatusOr, domain objects, protobuf messages/fields, or function return types. (link)

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Addressed in 8127c9b: replaced auto with the explicit return type.

state_enabled.OnRead(MakeResponse({{0, grpc::StatusCode::OK}}));
state_enabled.OnFinish(retry_status, /*enable_server_retries=*/true);
EXPECT_TRUE(state_enabled.HasPendingMutations());
auto const& req2 = state_enabled.BeforeStart();

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

According to the style guide, auto should not be used when it hides protobuf messages. Please use the explicit type google::bigtable::v2::MutateRowsRequest const& instead.

  google::bigtable::v2::MutateRowsRequest const& req2 =
      state_enabled.BeforeStart();
References
  1. Reject Obscured Domain & Return Types: Flag and reject auto when it hides StatusOr, domain objects, protobuf messages/fields, or function return types. (link)

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Addressed in 8127c9b: replaced auto with the explicit return type.

@sushanb

sushanb commented Dec 2, 2026

Copy link
Copy Markdown
Contributor Author

Addressed the review comments in 8127c9b: replaced auto with explicit types in async_bulk_apply_test.cc and bulk_mutator_test.cc.

@codecov

codecov Bot commented Dec 2, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 92.87%. Comparing base (b79eac3) to head (70e91db).
⚠️ Report is 9 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main   #16739      +/-   ##
==========================================
+ Coverage   92.85%   92.87%   +0.01%     
==========================================
  Files        2279     2279              
  Lines      230285   230423     +138     
==========================================
+ Hits       213839   213995     +156     
+ Misses      16446    16428      -18     

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@scotthart scotthart left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Re-checked at 8127c9bad5: the production fix in AsyncBulkApplier::OnFinish, the removal of the = false default parameter on BulkMutatorState::OnFinish, and the explicit type cleanup in 8127c9bad5 all look good.

One remaining suggestion on google/cloud/bigtable/internal/async_bulk_apply_test.cc:742-800 (RetryInfoIgnoredNonIdempotent): because StatusCode::kResourceExhausted is treated as permanent by SafeGrpcRetry, internal::Backoff(..., /*enable_server_retries=*/false) stops retries even if AsyncBulkApplier::OnFinish passed true to state_.OnFinish. Using TransientError() (StatusCode::kUnavailable) with RetryInfo (or adding a test case for it) ensures the test specifically verifies that state_.OnFinish receives enable_server_retries_ == false and does not keep the unconfirmed non-idempotent mutation pending.

@sushanb

sushanb commented Dec 3, 2026

Copy link
Copy Markdown
Contributor Author

Addressed the review comment in 70e91dbc0:

  • Updated AsyncBulkApplyTest.RetryInfoIgnoredNonIdempotent to return TransientError() (StatusCode::kUnavailable) with RetryInfo so the test specifically exercises AsyncBulkApplier::OnFinish forwarding enable_server_retries_ == false to BulkMutatorState::OnFinish rather than stopping via SafeGrpcRetry.

@sushanb
sushanb requested a review from scotthart December 3, 2026 21:38

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

api: bigtable Issues related to the Bigtable API.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants